package com.vcredit.creditcat.framework.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
/**
 * 默认控制层拦截器
 *为前台页面提供项目名等
 */
public class DefaultControllerInterceptor extends HandlerInterceptorAdapter {
	@Value("${app.name}")
	private String appRoot;
	@Value("${app.root}")
	private String appName; 
	
	public String getAppRoot() {
		return appRoot; 
	}
	
	public void setAppRoot(String appRoot) {
		this.appRoot = appRoot;
	}

	public String getAppName() {
		return appName;
	}

	public void setAppName(String appName) {
		this.appName = appName;
	}
	
	@Override
	public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
		if (modelAndView != null) {			
			modelAndView.addObject("appRoot", appRoot);
			modelAndView.addObject("appName", appName);
		}
	}
}